package com.changlu._01单例设计模式;

/**
 * @ClassName HungryTest
 * @Author ChangLu
 * @Date 2022/2/16 18:12
 * @Description 饿汉式
 */
public class HungrySingleton {

    //1、设置为static
    private static HungrySingleton instance = new HungrySingleton();

    //2、构造器私有
    private HungrySingleton(){
    }

    //3、获取单例方法为static
    public static HungrySingleton getInstance(){
        return instance;
    }

    //测试
    public static void main(String[] args) {
        System.out.println(HungrySingleton.getInstance());
    }

}